<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<div th:fragment="header" class="fly-header">
  <div class="layui-container">
    <a class="fly-logo" th:href="@{/}" href="/">
      <img th:src="@{/res/images/logo.png}" alt="程亮云社区">
    </a>

    <ul class="layui-nav layui-layout-left layui-hide-xs">
      <li class="layui-nav-item"><span class="fly-search"><i class="layui-icon"></i></span></li>
    </ul>

    <ul class="layui-nav layui-layout-right fly-nav-user">
      <li class="layui-nav-item layui-hide-xs" th:classappend="${nowColumnType == null?'layui-this':''}"><a th:href="@{/}" >首页</a></li>
      <li class="layui-nav-item layui-hide-xs" th:each="columnType,iterStat : ${columnTypes}" th:classappend="${columnType == nowColumnType?'layui-this':''}" th:if="${iterStat.index != 0}">
        <a th:href="@{'/q/'+${columnType.name()}}"  th:text="${columnType.describe}">提问</a>
      </li>
      <li class="layui-nav-item " sec:authorize="isAnonymous()"><a th:href="@{/user/login}" >登录/注册</a></li>
      <li class="layui-nav-item " sec:authorize="isAuthenticated()">
        <a class="fly-nav-avatar" href="javascript:;">
          <cite class="layui-hide-xs" th:text="${#authentication.principal?.user?.userNickName}">贤心</cite>
          <img th:src="@{${#authentication.principal?.user?.userAvatar}}">
        </a>
        <dl class="layui-nav-child layui-anim layui-anim-upbit">
          <dd><a th:href="@{/user/index}">用户中心</a></dd>
          <dd><a th:href="@{/user/set}">基本设置</a></dd>
          <hr style="margin: 5px 0;">
          <dd><a th:href="@{/user/home}">我的主页</a></dd>
          <dd><a th:href="@{/user/message}">我的消息</a></dd>
          <hr style="margin: 5px 0;">
          <dd><a th:href="@{/user/logout}" style="text-align: center;">退出</a></dd>
        </dl>
      </li>
      </li>
    </ul>

       <!-- <ul class="layui-nav fly-nav-user">
          <th:block sec:authorize="isAnonymous()">
            &lt;!&ndash; 未登入的状态 &ndash;&gt;
            <li class="layui-nav-item">
              <a th:href="@{/user/login}" >登录</a>
            </li>
            <li class="layui-nav-item">
              <a th:href="@{/user/reg}" >注册</a>
            </li>
            <li class="layui-nav-item layui-hide-xs">
              <a th:href="@{/user/login/qq/}" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" title="QQ登入" class="iconfont icon-qq"></a>
            </li>
          </th:block>
          &lt;!&ndash; 登入后的状态 &ndash;&gt;
          <th:block sec:authorize="isAuthenticated()">
            <li class="layui-nav-item">
              <a class="fly-nav-avatar" href="javascript:;">
                <cite class="layui-hide-xs" th:text="${#authentication.principal?.user?.userNickName}">贤心</cite>
                <img th:src="@{${#authentication.principal?.user?.userAvatar}}">
              </a>
              <dl class="layui-nav-child layui-anim layui-anim-upbit">
                <dd><a th:href="@{/user/index}">用户中心</a></dd>
                <dd><a th:href="@{/user/set}">基本设置</a></dd>
                <hr style="margin: 5px 0;">
                <dd><a th:href="@{/user/home}">我的主页</a></dd>
                <dd><a th:href="@{/user/message}">我的消息</a></dd>
                <hr style="margin: 5px 0;">
                <dd><a th:href="@{/user/logout}" style="text-align: center;">退出</a></dd>
              </dl>
            </li>
          </th:block>
        </ul>-->
  </div>
</div>